
/* SPF (Sender Policy Framework) implementation.

Copyright (c) 2007 Roberto Alsina <ralsina@kde.org>
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

For more information about SPF, a tool against email forgery, see
http://www.openspf.org/

For new versions check out http://code.google.com/p/raspf

*/

#include <stdlib.h>
#include <stdio.h>
#include <check.h>
#include "raspf.h"



//Test 1: emptylabel
//No description
//Scenario: Initial processing
//CLI: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A...example.com'

START_TEST (zonedata_Initial_processing_1)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Initial_processing",1);
    spf_init();
    r=spf_check("1.2.3.5","lyme.eater@A...example.com","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: none\nGot: %s\nTest with: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A...example.com'\n",r.response);
    fail_unless(0==strcmp("none",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 2: toolonglabel
//Description: DNS labels limited to 63 chars.
//Scenario: Initial processing
//CLI: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A123456789012345678901234567890123456789012345678901234567890123.example.com'

START_TEST (zonedata_Initial_processing_2)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Initial_processing",1);
    spf_init();
    r=spf_check("1.2.3.5","lyme.eater@A123456789012345678901234567890123456789012345678901234567890123.example.com","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: none\nGot: %s\nTest with: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A123456789012345678901234567890123456789012345678901234567890123.example.com'\n",r.response);
    fail_unless(0==strcmp("none",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 3: longlabel
//Description: DNS labels limited to 63 chars.
//Scenario: Initial processing
//CLI: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A12345678901234567890123456789012345678901234567890123456789012.example.com'

START_TEST (zonedata_Initial_processing_3)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Initial_processing",1);
    spf_init();
    r=spf_check("1.2.3.5","lyme.eater@A12345678901234567890123456789012345678901234567890123456789012.example.com","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.5' --helo 'mail.example.net' --sender 'lyme.eater@A12345678901234567890123456789012345678901234567890123456789012.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 4: nolocalpart
//No description
//Scenario: Initial processing
//CLI: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender '@example.net'

START_TEST (zonedata_Initial_processing_4)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Initial_processing",1);
    spf_init();
    r=spf_check("1.2.3.4","@example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Initial_processing ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender '@example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 5: alltimeout
//Description: Both TXT and SPF queries time out
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@alltimeout.example.net'

START_TEST (zonedata_Record_lookup_5)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@alltimeout.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: temperror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@alltimeout.example.net'\n",r.response);
    fail_unless(0==strcmp("temperror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 6: both
//No description
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@both.example.net'

START_TEST (zonedata_Record_lookup_6)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@both.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@both.example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 7: txttimeout
//Description: SPF record present, but TXT lookup times out. If only TXT records are checked, result is temperror.
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txttimeout.example.net'

START_TEST (zonedata_Record_lookup_7)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@txttimeout.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txttimeout.example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("temperror",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txttimeout.example.net'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 8: spfonly
//Description: Result is none if checking TXT records only.
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spfonly.example.net'

START_TEST (zonedata_Record_lookup_8)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@spfonly.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spfonly.example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("none",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spfonly.example.net'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 9: spftimeout
//Description: TXT record present, but SPF lookup times out. Result is temperror if checking SPF records only.
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spftimeout.example.net'

START_TEST (zonedata_Record_lookup_9)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@spftimeout.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spftimeout.example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("temperror",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@spftimeout.example.net'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 10: nospftxttimeout
//Description: No SPF record present, and TXT lookup times out. If only TXT records are checked, result is temperror.
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@nospftxttimeout.example.net'

START_TEST (zonedata_Record_lookup_10)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@nospftxttimeout.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: ['temperror', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@nospftxttimeout.example.net'\n",r.response);
    fail_unless(0==strcmp("temperror",r.response) || 0==strcmp("none",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['temperror', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@nospftxttimeout.example.net'\n",r.response);
    fail_if(strcmp("temperror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 11: txtonly
//Description: Result is none if checking SPF records only.
//Scenario: Record lookup
//CLI: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txtonly.example.net'

START_TEST (zonedata_Record_lookup_11)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_lookup",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@txtonly.example.net","mail.example.net",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txtonly.example.net'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("none",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'none']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_lookup ./raspfquery --ip '1.2.3.4' --helo 'mail.example.net' --sender 'foo@txtonly.example.net'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 12: nospace2
//No description
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example3.com'

START_TEST (zonedata_Selecting_records_12)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example3.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example3.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 13: nospace1
//Description: Version must be terminated by space or end of record.  TXT pieces are joined without intervening spaces.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example2.com'

START_TEST (zonedata_Selecting_records_13)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example2.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: none\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example2.com'\n",r.response);
    fail_unless(0==strcmp("none",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 14: spfoverride
//Description: SPF records override TXT records.  Older implementation may check TXT records only.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example4.com'

START_TEST (zonedata_Selecting_records_14)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example4.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: ['pass', 'fail']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example4.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response) || 0==strcmp("fail",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['pass', 'fail']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example4.com'\n",r.response);
    fail_if(strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 15: nospf
//No description
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@mail.example1.com'

START_TEST (zonedata_Selecting_records_15)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@mail.example1.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: none\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@mail.example1.com'\n",r.response);
    fail_unless(0==strcmp("none",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 16: multispf1
//Description: Multiple records is a permerror, even when they are identical.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example7.com'

START_TEST (zonedata_Selecting_records_16)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example7.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example7.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 17: multitxt2
//Description: Multiple records is a permerror, v=spf1 is case insensitive
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example6.com'

START_TEST (zonedata_Selecting_records_17)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example6.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example6.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 18: multitxt1
//Description: Older implementations will give permerror/unknown because of the conflicting TXT records.  However, RFC 4408 says the SPF records overrides them.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example5.com'

START_TEST (zonedata_Selecting_records_18)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example5.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: ['pass', 'permerror']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example5.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response) || 0==strcmp("permerror",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['pass', 'permerror']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example5.com'\n",r.response);
    fail_if(strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 19: case-insensitive
//Description: v=spf1 is case insensitive
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example9.com'

START_TEST (zonedata_Selecting_records_19)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example9.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: softfail\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example9.com'\n",r.response);
    fail_unless(0==strcmp("softfail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 20: multispf2
//Description: Older implementations will give pass because there is a single TXT record.  But RFC 4408 requires permerror because the SPF records override and there are more than one.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example8.com'

START_TEST (zonedata_Selecting_records_20)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example8.com","mail.example1.com",0,0);
    sprintf(buffer,"\nExpected: ['permerror', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example8.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response) || 0==strcmp("pass",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['permerror', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail.example1.com' --sender 'foo@example8.com'\n",r.response);
    fail_if(strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 21: empty
//Description: Empty SPF record.
//Scenario: Selecting records
//CLI: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail1.example1.com' --sender 'foo@example1.com'

START_TEST (zonedata_Selecting_records_21)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Selecting_records",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@example1.com","mail1.example1.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_Selecting_records ./raspfquery --ip '1.2.3.4' --helo 'mail1.example1.com' --sender 'foo@example1.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 22: modifier-charset-bad2
//Description: '=' character immediately after the name and before any ":" or "/"
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t4.example.com'

START_TEST (zonedata_Record_evaluation_22)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t4.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 23: modifier-charset-bad1
//Description: '=' character immediately after the name and before any ":" or "/"
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t3.example.com'

START_TEST (zonedata_Record_evaluation_23)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 24: redirect-after-mechanisms2
//Description: The "redirect" modifier has an effect after all the mechanisms.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@t6.example.com'

START_TEST (zonedata_Record_evaluation_24)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@t6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@t6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 25: detect-errors-anywhere
//Description: Any syntax errors anywhere in the record MUST be detected.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t1.example.com'

START_TEST (zonedata_Record_evaluation_25)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 26: redirect-after-mechanisms1
//Description: The "redirect" modifier has an effect after all the mechanisms.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t5.example.com'

START_TEST (zonedata_Record_evaluation_26)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: softfail\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t5.example.com'\n",r.response);
    fail_unless(0==strcmp("softfail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 27: invalid-domain
//Description: Domain-spec must end in macro-expand or valid toplabel.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t9.example.com'

START_TEST (zonedata_Record_evaluation_27)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 28: modifier-charset-good
//Description: name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t2.example.com'

START_TEST (zonedata_Record_evaluation_28)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 29: invalid-domain-empty-label
//Description: Domain-spec must end in macro-expand or valid toplabel.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t10.example.com'

START_TEST (zonedata_Record_evaluation_29)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t10.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("temperror",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t10.example.com'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 30: invalid-domain-long
//Description: Domain-spec must end in macro-expand or valid toplabel.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo '%%%%%%%%%%%%%%%%%%%%%%' --sender 'foo@t11.example.com'

START_TEST (zonedata_Record_evaluation_30)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t11.example.com","%%%%%%%%%%%%%%%%%%%%%%",0,0);
    sprintf(buffer,"\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo '%%%%%%%%%%%%%%%%%%%%%%' --sender 'foo@t11.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response) || 0==strcmp("temperror",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['fail', 'temperror']\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo '%%%%%%%%%%%%%%%%%%%%%%' --sender 'foo@t11.example.com'\n",r.response);
    fail_if(strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 31: redirect-is-modifier
//Description: Invalid mechanism.  Redirect is a modifier.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t8.example.com'

START_TEST (zonedata_Record_evaluation_31)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@t8.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@t8.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 32: default-result
//Description: Default result is neutral.
//Scenario: Record evaluation
//CLI: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@t7.example.com'

START_TEST (zonedata_Record_evaluation_32)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Record_evaluation",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@t7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_Record_evaluation ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@t7.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 33: all-arg
//Description: all              = "all" 
//Scenario: ALL mechanism syntax
//CLI: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_ALL_mechanism_syntax_33)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_ALL_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 34: all-dot
//Description: all              = "all" 
//Scenario: ALL mechanism syntax
//CLI: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_ALL_mechanism_syntax_34)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_ALL_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 35: all-cidr
//Description: all              = "all" 
//Scenario: ALL mechanism syntax
//CLI: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_ALL_mechanism_syntax_35)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_ALL_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 36: all-neutral
//Description: all              = "all" 
//Scenario: ALL mechanism syntax
//CLI: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_ALL_mechanism_syntax_36)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_ALL_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 37: all-double
//Description: all              = "all" 
//Scenario: ALL mechanism syntax
//CLI: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_ALL_mechanism_syntax_37)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_ALL_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_ALL_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 38: ptr-nomatch-invalid
//Description: Check all validated domain names to see if they end in the <target-name> domain.
//Scenario: PTR mechanism syntax
//CLI: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_PTR_mechanism_syntax_38)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_PTR_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 39: ptr-match-target
//Description: Check all validated domain names to see if they end in the <target-name> domain.
//Scenario: PTR mechanism syntax
//CLI: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_PTR_mechanism_syntax_39)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_PTR_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 40: ptr-match-ip6
//Description: Check all validated domain names to see if they end in the <target-name> domain.
//Scenario: PTR mechanism syntax
//CLI: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip 'CAFE:BABE::1' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_PTR_mechanism_syntax_40)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_PTR_mechanism_syntax",1);
    spf_init();
    r=spf_check("CAFE:BABE::1","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip 'CAFE:BABE::1' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 41: ptr-match-implicit
//Description: Check all validated domain names to see if they end in the <target-name> domain.
//Scenario: PTR mechanism syntax
//CLI: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_PTR_mechanism_syntax_41)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_PTR_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 42: ptr-cidr
//Description: PTR              = "ptr"    [ ":" domain-spec ]
//Scenario: PTR mechanism syntax
//CLI: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_PTR_mechanism_syntax_42)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_PTR_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_PTR_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 43: a-bad-toplab
//Description: Toplabel may not begin with -
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'

START_TEST (zonedata_A_mechanism_syntax_43)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e12.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 44: a-numeric-top-label
//Description: Top-label may not be all numeric
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_A_mechanism_syntax_44)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 45: a-cidr4-0
//Description: Matches if any A records are present in DNS.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_A_mechanism_syntax_45)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 46: a-bad-domain
//Description: domain-spec must pass basic syntax checks, 
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'

START_TEST (zonedata_A_mechanism_syntax_46)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 47: a-colon-domain-ip4mapped
//Description: Domain-spec may contain any visible char except %
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'

START_TEST (zonedata_A_mechanism_syntax_47)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e11.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 48: a-colon-domain
//Description: Domain-spec may contain any visible char except %
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'

START_TEST (zonedata_A_mechanism_syntax_48)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e11.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 49: a-cidr6-0-ip6
//Description: Matches if any AAAA records are present in DNS.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_A_mechanism_syntax_49)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 50: a-multi-ip1
//Description: A matches any returned IP.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'

START_TEST (zonedata_A_mechanism_syntax_50)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 51: a-cidr6-0-ip4
//Description: Would match if any AAAA records are present in DNS, but not for an IP4 connection.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_A_mechanism_syntax_51)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 52: a-multi-ip2
//Description: A matches any returned IP.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'

START_TEST (zonedata_A_mechanism_syntax_52)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 53: a-cidr6-0-ip4mapped
//Description: Would match if any AAAA records are present in DNS, but not for an IP4 connection.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_A_mechanism_syntax_53)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 54: a-cidr6-0-nxdomain
//Description: No match if no AAAA records are present in DNS.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2b.example.com'

START_TEST (zonedata_A_mechanism_syntax_54)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2b.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2b.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 55: a-bad-cidr4
//Description: A                = "a"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6a.example.com'

START_TEST (zonedata_A_mechanism_syntax_55)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6a.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 56: a-bad-cidr6
//Description: A                = "a"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_A_mechanism_syntax_56)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 57: a-cidr4-0-ip6
//Description: Matches if any A records are present in DNS.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_A_mechanism_syntax_57)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 58: a-numeric
//Description: Top-label may not be all numeric
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_A_mechanism_syntax_58)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 59: a-cidr6
//Description: A                = "a"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_A_mechanism_syntax_59)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 60: a-nxdomain
//Description: If no ips are returned, A mechanism does not match, even with /0.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_A_mechanism_syntax_60)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 61: a-null
//Description: Null not allowed in top-label.
//Scenario: A mechanism syntax
//CLI: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_A_mechanism_syntax_61)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_A_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_A_mechanism_syntax ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 62: include-neutral
//Description: recursive check_host() result of neutral causes include to not match.
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_62)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 63: include-temperror
//Description: recursive check_host() result of temperror causes include to temperror
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_63)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: temperror\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("temperror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 64: include-none
//Description: recursive check_host() result of none causes include to permerror
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_64)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 65: include-softfail
//Description: recursive check_host() result of softfail causes include to not match.
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_65)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 66: include-fail
//Description: recursive check_host() result of fail causes include to not match.
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_66)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: softfail\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("softfail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 67: include-syntax-error
//Description: include          = "include"  ":" domain-spec
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_67)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 68: include-permerror
//Description: recursive check_host() result of permerror causes include to permerror
//Scenario: Include mechanism semantics and syntax
//CLI: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_Include_mechanism_semantics_and_syntax_68)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Include_mechanism_semantics_and_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Include_mechanism_semantics_and_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 69: mx-empty
//Description: test null MX
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender ''

START_TEST (zonedata_MX_mechanism_syntax_69)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender ''\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 70: mx-colon-domain-ip4mapped
//Description: Domain-spec may contain any visible char except %
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'

START_TEST (zonedata_MX_mechanism_syntax_70)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e11.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 71: mx-numeric-top-label
//Description: Top-label may not be all numeric
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_MX_mechanism_syntax_71)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 72: mx-null
//Description: Null not allowed in top-label.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_MX_mechanism_syntax_72)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 73: mx-cidr6-0-ip6
//Description: Matches if any AAAA records for any MX records are present in DNS.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_MX_mechanism_syntax_73)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 74: mx-cidr6-0-ip4
//Description: Would match if any AAAA records for MX records are present in DNS, but not for an IP4 connection.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_MX_mechanism_syntax_74)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 75: mx-cidr6-0-nxdomain
//Description: No match if no AAAA records for any MX records are present in DNS.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2b.example.com'

START_TEST (zonedata_MX_mechanism_syntax_75)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2b.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2b.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 76: mx-cidr6
//Description: MX                = "mx"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_MX_mechanism_syntax_76)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 77: mx-bad-cidr6
//Description: MX                = "mx"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_MX_mechanism_syntax_77)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 78: mx-bad-domain
//Description: domain-spec must pass basic syntax checks, 
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'

START_TEST (zonedata_MX_mechanism_syntax_78)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 79: mx-cidr4-0
//Description: Matches if any A records for any MX records are present in DNS.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_MX_mechanism_syntax_79)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 80: mx-nxdomain
//Description: If no ips are returned, MX mechanism does not match, even with /0.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_MX_mechanism_syntax_80)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 81: mx-bad-cidr4
//Description: MX                = "mx"      [ ":" domain-spec ] [ dual-cidr-length ] dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6a.example.com'

START_TEST (zonedata_MX_mechanism_syntax_81)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6a.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 82: mx-bad-toplab
//Description: Toplabel may not begin with -
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'

START_TEST (zonedata_MX_mechanism_syntax_82)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e12.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 83: mx-implicit
//Description: If the target name has no MX records, check_host() MUST NOT pretend the target is its single MX, and MUST NOT default to an A lookup on the target-name directly.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_MX_mechanism_syntax_83)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 84: mx-multi-ip1
//Description: MX matches any returned IP.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'

START_TEST (zonedata_MX_mechanism_syntax_84)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 85: mx-colon-domain
//Description: Domain-spec may contain any visible char except %
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'

START_TEST (zonedata_MX_mechanism_syntax_85)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e11.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 86: mx-multi-ip2
//Description: MX matches any returned IP.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'

START_TEST (zonedata_MX_mechanism_syntax_86)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 87: mx-cidr6-0-ip4mapped
//Description: Would match if any AAAA records for MX records are present in DNS, but not for an IP4 connection.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'

START_TEST (zonedata_MX_mechanism_syntax_87)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e2a.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2a.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 88: mx-cidr4-0-ip6
//Description: Matches if any A records for any MX records are present in DNS.
//Scenario: MX mechanism syntax
//CLI: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_MX_mechanism_syntax_88)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_MX_mechanism_syntax",1);
    spf_init();
    r=spf_check("1234::1","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_MX_mechanism_syntax ./raspfquery --ip '1234::1' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 89: cidr4-0
//Description: ip4-cidr-length  = "/" 1*DIGIT
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_89)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 90: cidr4-32
//Description: ip4-cidr-length  = "/" 1*DIGIT
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_90)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 91: cidr4-33
//Description: Invalid CIDR should get permerror.
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_91)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 92: bad-ip4-short
//Description: It is not permitted to omit parts of the IP address instead of using CIDR notations.
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_92)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 93: bare-ip4
//Description: IP4              = "ip4"      ":" ip4-network   [ ip4-cidr-length ]
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_93)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 94: cidr4-032
//Description: Invalid CIDR should get permerror.
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_94)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 95: ip4-dual-cidr
//Description: dual-cidr-length not permitted on ip4
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_95)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 96: bad-ip4-port
//Description: IP4              = "ip4"      ":" ip4-network   [ ip4-cidr-length ]
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e8.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_96)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e8.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e8.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 97: ip4-mapped-ip6
//Description: IP4 mapped IP6 connections MUST be treated as IP4
//Scenario: IP4 mechanism syntax
//CLI: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_IP4_mechanism_syntax_97)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP4_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_IP4_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 98: bare-ip6
//Description: IP6              = "ip6"      ":" ip6-network   [ ip6-cidr-length ]
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_98)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 99: ip6-bad1
//Description: 
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_99)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 100: cidr6-33
//Description: make sure ip4 cidr restriction are not used for ip6
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip 'CAFE:BABE:8000::' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_100)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("CAFE:BABE:8000::","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip 'CAFE:BABE:8000::' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 101: cidr6-0
//Description: Match any IP6
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip 'DEAF:BABE::CAB:FEE' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_101)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("DEAF:BABE::CAB:FEE","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip 'DEAF:BABE::CAB:FEE' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 102: cidr6-ip4
//Description: Even if the SMTP connection is via IPv6, an IPv4-mapped IPv6 IP address (see RFC 3513, Section 2.5.5) MUST still be considered an IPv4 address.
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_102)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("::FFFF:1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response) || 0==strcmp("pass",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '::FFFF:1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_if(strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 103: cidr6-bad
//Description: dual-cidr syntax not used for ip6
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_103)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 104: cidr6-129
//Description: Invalid CIDR
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_104)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 105: cidr6-0-ip4
//Description: IP4 connections do not match ip6.
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_105)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response) || 0==strcmp("pass",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_if(strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 106: cidr6-33-ip4
//Description: make sure ip4 cidr restriction are not used for ip6
//Scenario: IP6 mechanism syntax
//CLI: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_IP6_mechanism_syntax_106)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_IP6_mechanism_syntax",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: neutral\nGot: %s\nTest with: ZONEDATA=zonedata_IP6_mechanism_syntax ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 107: redirect-cancels-exp
//Description: when executing "redirect", exp= from the original domain MUST NOT be used.
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_107)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 108: redirect-none
//Description: If no SPF record is found, or if the target-name is malformed, the result is a "PermError" rather than "None".
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_108)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e10.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 109: exp-syntax-error
//Description: Ignore exp if syntax error. 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e13.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_109)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e13.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e13.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 110: empty-modifier-name
//Description: name             = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_110)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 111: exp-twice
//Description: exp= appears twice. 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e14.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_111)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e14.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e14.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 112: exp-multiple-txt
//Description: Ignore exp if multiple TXT records. 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_112)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e11.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e11.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 113: redirect-twice
//Description: redirect= appears twice. 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e15.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_113)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e15.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e15.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 114: exp-empty-domain
//Description: Ignore exp if empty domain-spec. 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_114)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e12.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e12.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 115: unknown-modifier-syntax
//Description: unknown-modifier = name "=" macro-string 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_115)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 116: invalid-modifier
//Description: unknown-modifier = name "=" macro-string name             = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) 
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_116)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 117: dorky-sentinel
//Description: An implementation that uses a legal expansion as a sentinel.  We cannot check them all, but we can check this one.
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'Macro Error@e8.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_117)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","Macro Error@e8.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'Macro Error@e8.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 118: redirect-cancels-prior-exp
//Description: when executing "redirect", exp= from the original domain MUST NOT be used.
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_118)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e3.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 119: include-ignores-exp
//Description: when executing "include", exp= from the target domain MUST NOT be used.
//Scenario: Semantics of exp and other modifiers
//CLI: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_Semantics_of_exp_and_other_modifiers_119)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Semantics_of_exp_and_other_modifiers",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Semantics_of_exp_and_other_modifiers ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 120: p-macro-ip4-valid
//Description: p	= the validated domain name of <ip>
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.41' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'

START_TEST (zonedata_Macro_expansion_rules_120)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.41","test@e6.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.41' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 121: domain-name-truncation
//Description: When the result of macro expansion is used in a domain name query, if the expanded domain name exceeds 253 characters, the left side is truncated to fit, by removing successive domain labels until the total length does not exceed 253 characters.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@somewhat.long.exp.example.com'

START_TEST (zonedata_Macro_expansion_rules_121)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@somewhat.long.exp.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@somewhat.long.exp.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 122: trailing-dot-exp
//Description: trailing dot is not removed from explanation
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@exp.example.com'

START_TEST (zonedata_Macro_expansion_rules_122)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@exp.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@exp.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 123: p-macro-ip6-valid
//Description: p	= the validated domain name of <ip>
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::3' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'

START_TEST (zonedata_Macro_expansion_rules_123)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("CAFE:BABE::3","test@e6.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::3' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 124: invalid-macro-char
//Description: A '%' character not followed by a '{', '%', '-', or '_' character is a syntax error.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e1.example.com'

START_TEST (zonedata_Macro_expansion_rules_124)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e1.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 125: p-macro-ip6-novalid
//Description: p	= the validated domain name of <ip>
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::1' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'

START_TEST (zonedata_Macro_expansion_rules_125)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("CAFE:BABE::1","test@e6.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::1' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 126: undef-macro
//Description: Allowed macros chars are 'slodipvh' plus 'crt' in explanation.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e5.example.com'

START_TEST (zonedata_Macro_expansion_rules_126)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("CAFE:BABE::192.168.218.40","test@e5.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 127: p-macro-ip4-novalid
//Description: p	= the validated domain name of <ip>
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'

START_TEST (zonedata_Macro_expansion_rules_127)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e6.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 128: require-valid-helo
//Description: Example of requiring valid helo in sender policy.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '1.2.3.4' --helo 'OEMCOMPUTER' --sender 'test@e10.example.com'

START_TEST (zonedata_Macro_expansion_rules_128)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("1.2.3.4","test@e10.example.com","OEMCOMPUTER",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '1.2.3.4' --helo 'OEMCOMPUTER' --sender 'test@e10.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 129: p-macro-multiple
//Description: p	= the validated domain name of <ip>
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.42' --helo 'msgbas2x.cos.example.com' --sender 'test@e7.example.com'

START_TEST (zonedata_Macro_expansion_rules_129)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.42","test@e7.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: ['pass', 'softfail']\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.42' --helo 'msgbas2x.cos.example.com' --sender 'test@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response) || 0==strcmp("softfail",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['pass', 'softfail']\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.42' --helo 'msgbas2x.cos.example.com' --sender 'test@e7.example.com'\n",r.response);
    fail_if(strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 130: invalid-hello-macro
//Description: h	= HELO/EHLO domain, but HELO is invalid
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'JUMPIN' JUPITER' --sender 'test@e9.example.com'

START_TEST (zonedata_Macro_expansion_rules_130)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e9.example.com","JUMPIN' JUPITER",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'JUMPIN' JUPITER' --sender 'test@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 131: exp-txt-macro-char
//Description: For IPv4 addresses, both the "i" and "c" macros expand to the standard dotted-quad format.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e3.example.com'

START_TEST (zonedata_Macro_expansion_rules_131)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e3.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e3.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 132: exp-only-macro-char
//Description: The following macro letters are allowed only in "exp" text: c, r, t
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e2.example.com'

START_TEST (zonedata_Macro_expansion_rules_132)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e2.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 133: trailing-dot-domain
//Description: trailing dot is ignored for domains
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@example.com'

START_TEST (zonedata_Macro_expansion_rules_133)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 134: upper-macro
//Description: Uppercased macros expand exactly as their lowercased equivalents,  and are then URL escaped.
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.42' --helo 'msgbas2x.cos.example.com' --sender 'jack&jill=up@e8.example.com'

START_TEST (zonedata_Macro_expansion_rules_134)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.42","jack&jill=up@e8.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.42' --helo 'msgbas2x.cos.example.com' --sender 'jack&jill=up@e8.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 135: hello-macro
//Description: h	= HELO/EHLO domain
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e9.example.com'

START_TEST (zonedata_Macro_expansion_rules_135)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e9.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 136: v-macro-ip4
//Description: v	= the string "in-addr" if <ip> is ipv4, or "ip6" if <ip> is ipv6
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e4.example.com'

START_TEST (zonedata_Macro_expansion_rules_136)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("192.168.218.40","test@e4.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip '192.168.218.40' --helo 'msgbas2x.cos.example.com' --sender 'test@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 137: v-macro-ip6
//Description: v	= the string "in-addr" if <ip> is ipv4, or "ip6" if <ip> is ipv6
//Scenario: Macro expansion rules
//CLI: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::1' --helo 'msgbas2x.cos.example.com' --sender 'test@e4.example.com'

START_TEST (zonedata_Macro_expansion_rules_137)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Macro_expansion_rules",1);
    spf_init();
    r=spf_check("CAFE:BABE::1","test@e4.example.com","msgbas2x.cos.example.com",0,0);
    sprintf(buffer,"\nExpected: fail\nGot: %s\nTest with: ZONEDATA=zonedata_Macro_expansion_rules ./raspfquery --ip 'CAFE:BABE::1' --helo 'msgbas2x.cos.example.com' --sender 'test@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("fail",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 138: include-at-limit
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e8.example.com'

START_TEST (zonedata_Processing_limits_138)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e8.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e8.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 139: mx-limit
//Description: there MUST be a limit of no more than 10 MX looked up and checked.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e4.example.com'

START_TEST (zonedata_Processing_limits_139)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@e4.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response) || 0==strcmp("pass",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e4.example.com'\n",r.response);
    fail_if(strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 140: mech-over-limit
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'

START_TEST (zonedata_Processing_limits_140)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e7.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e7.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 141: ptr-limit
//Description: there MUST be a limit of no more than 10 PTR looked up and checked.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e5.example.com'

START_TEST (zonedata_Processing_limits_141)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.5","foo@e5.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_unless(0==strcmp("neutral",r.response) || 0==strcmp("pass",r.response),buffer);
    sprintf(buffer,"\nWARNING:\nExpected: ['neutral', 'pass']\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.5' --helo 'mail.example.com' --sender 'foo@e5.example.com'\n",r.response);
    fail_if(strcmp("neutral",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 142: include-over-limit
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'

START_TEST (zonedata_Processing_limits_142)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e9.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e9.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 143: redirect-loop
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'

START_TEST (zonedata_Processing_limits_143)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e1.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e1.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 144: mech-at-limit
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'

START_TEST (zonedata_Processing_limits_144)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e6.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: pass\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e6.example.com'\n",r.response);
    fail_unless(0==strcmp("pass",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST

//Test 145: include-loop
//Description: SPF implementations MUST limit the number of mechanisms and modifiers  that do DNS lookups to at most 10 per SPF check.
//Scenario: Processing limits
//CLI: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'

START_TEST (zonedata_Processing_limits_145)
{
    char buffer[1024];
    spf_response r;
    setenv ("ZONEDATA","/home/ralsina/Desktop/proyectos/qmail/raspf/svn/rfc4408-zonedata/zonedata_Processing_limits",1);
    spf_init();
    r=spf_check("1.2.3.4","foo@e2.example.com","mail.example.com",0,0);
    sprintf(buffer,"\nExpected: permerror\nGot: %s\nTest with: ZONEDATA=zonedata_Processing_limits ./raspfquery --ip '1.2.3.4' --helo 'mail.example.com' --sender 'foo@e2.example.com'\n",r.response);
    fail_unless(0==strcmp("permerror",r.response),buffer);
    free (r.response);
    free (r.explanation);
    spf_close();
}
END_TEST



Suite * spf_suite (void)
{
    Suite *s = suite_create ("SPF Official Suite");

    // Scenario: Initial processing

    TCase *zonedata_Initial_processing = tcase_create ("zonedata_Initial_processing");
    tcase_add_test(zonedata_Initial_processing,zonedata_Initial_processing_1);
    tcase_add_test(zonedata_Initial_processing,zonedata_Initial_processing_2);
    tcase_add_test(zonedata_Initial_processing,zonedata_Initial_processing_3);
    tcase_add_test(zonedata_Initial_processing,zonedata_Initial_processing_4);
    suite_add_tcase(s,zonedata_Initial_processing);

    // Scenario: Record lookup

    TCase *zonedata_Record_lookup = tcase_create ("zonedata_Record_lookup");
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_5);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_6);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_7);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_8);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_9);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_10);
    tcase_add_test(zonedata_Record_lookup,zonedata_Record_lookup_11);
    suite_add_tcase(s,zonedata_Record_lookup);

    // Scenario: Selecting records

    TCase *zonedata_Selecting_records = tcase_create ("zonedata_Selecting_records");
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_12);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_13);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_14);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_15);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_16);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_17);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_18);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_19);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_20);
    tcase_add_test(zonedata_Selecting_records,zonedata_Selecting_records_21);
    suite_add_tcase(s,zonedata_Selecting_records);

    // Scenario: Record evaluation

    TCase *zonedata_Record_evaluation = tcase_create ("zonedata_Record_evaluation");
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_22);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_23);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_24);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_25);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_26);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_27);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_28);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_29);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_30);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_31);
    tcase_add_test(zonedata_Record_evaluation,zonedata_Record_evaluation_32);
    suite_add_tcase(s,zonedata_Record_evaluation);

    // Scenario: ALL mechanism syntax

    TCase *zonedata_ALL_mechanism_syntax = tcase_create ("zonedata_ALL_mechanism_syntax");
    tcase_add_test(zonedata_ALL_mechanism_syntax,zonedata_ALL_mechanism_syntax_33);
    tcase_add_test(zonedata_ALL_mechanism_syntax,zonedata_ALL_mechanism_syntax_34);
    tcase_add_test(zonedata_ALL_mechanism_syntax,zonedata_ALL_mechanism_syntax_35);
    tcase_add_test(zonedata_ALL_mechanism_syntax,zonedata_ALL_mechanism_syntax_36);
    tcase_add_test(zonedata_ALL_mechanism_syntax,zonedata_ALL_mechanism_syntax_37);
    suite_add_tcase(s,zonedata_ALL_mechanism_syntax);

    // Scenario: PTR mechanism syntax

    TCase *zonedata_PTR_mechanism_syntax = tcase_create ("zonedata_PTR_mechanism_syntax");
    tcase_add_test(zonedata_PTR_mechanism_syntax,zonedata_PTR_mechanism_syntax_38);
    tcase_add_test(zonedata_PTR_mechanism_syntax,zonedata_PTR_mechanism_syntax_39);
    tcase_add_test(zonedata_PTR_mechanism_syntax,zonedata_PTR_mechanism_syntax_40);
    tcase_add_test(zonedata_PTR_mechanism_syntax,zonedata_PTR_mechanism_syntax_41);
    tcase_add_test(zonedata_PTR_mechanism_syntax,zonedata_PTR_mechanism_syntax_42);
    suite_add_tcase(s,zonedata_PTR_mechanism_syntax);

    // Scenario: A mechanism syntax

    TCase *zonedata_A_mechanism_syntax = tcase_create ("zonedata_A_mechanism_syntax");
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_43);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_44);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_45);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_46);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_47);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_48);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_49);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_50);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_51);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_52);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_53);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_54);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_55);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_56);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_57);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_58);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_59);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_60);
    tcase_add_test(zonedata_A_mechanism_syntax,zonedata_A_mechanism_syntax_61);
    suite_add_tcase(s,zonedata_A_mechanism_syntax);

    // Scenario: Include mechanism semantics and syntax

    TCase *zonedata_Include_mechanism_semantics_and_syntax = tcase_create ("zonedata_Include_mechanism_semantics_and_syntax");
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_62);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_63);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_64);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_65);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_66);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_67);
    tcase_add_test(zonedata_Include_mechanism_semantics_and_syntax,zonedata_Include_mechanism_semantics_and_syntax_68);
    suite_add_tcase(s,zonedata_Include_mechanism_semantics_and_syntax);

    // Scenario: MX mechanism syntax

    TCase *zonedata_MX_mechanism_syntax = tcase_create ("zonedata_MX_mechanism_syntax");
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_69);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_70);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_71);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_72);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_73);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_74);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_75);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_76);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_77);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_78);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_79);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_80);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_81);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_82);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_83);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_84);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_85);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_86);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_87);
    tcase_add_test(zonedata_MX_mechanism_syntax,zonedata_MX_mechanism_syntax_88);
    suite_add_tcase(s,zonedata_MX_mechanism_syntax);

    // Scenario: IP4 mechanism syntax

    TCase *zonedata_IP4_mechanism_syntax = tcase_create ("zonedata_IP4_mechanism_syntax");
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_89);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_90);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_91);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_92);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_93);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_94);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_95);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_96);
    tcase_add_test(zonedata_IP4_mechanism_syntax,zonedata_IP4_mechanism_syntax_97);
    suite_add_tcase(s,zonedata_IP4_mechanism_syntax);

    // Scenario: IP6 mechanism syntax

    TCase *zonedata_IP6_mechanism_syntax = tcase_create ("zonedata_IP6_mechanism_syntax");
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_98);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_99);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_100);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_101);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_102);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_103);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_104);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_105);
    tcase_add_test(zonedata_IP6_mechanism_syntax,zonedata_IP6_mechanism_syntax_106);
    suite_add_tcase(s,zonedata_IP6_mechanism_syntax);

    // Scenario: Semantics of exp and other modifiers

    TCase *zonedata_Semantics_of_exp_and_other_modifiers = tcase_create ("zonedata_Semantics_of_exp_and_other_modifiers");
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_107);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_108);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_109);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_110);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_111);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_112);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_113);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_114);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_115);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_116);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_117);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_118);
    tcase_add_test(zonedata_Semantics_of_exp_and_other_modifiers,zonedata_Semantics_of_exp_and_other_modifiers_119);
    suite_add_tcase(s,zonedata_Semantics_of_exp_and_other_modifiers);

    // Scenario: Macro expansion rules

    TCase *zonedata_Macro_expansion_rules = tcase_create ("zonedata_Macro_expansion_rules");
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_120);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_121);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_122);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_123);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_124);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_125);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_126);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_127);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_128);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_129);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_130);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_131);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_132);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_133);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_134);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_135);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_136);
    tcase_add_test(zonedata_Macro_expansion_rules,zonedata_Macro_expansion_rules_137);
    suite_add_tcase(s,zonedata_Macro_expansion_rules);

    // Scenario: Processing limits

    TCase *zonedata_Processing_limits = tcase_create ("zonedata_Processing_limits");
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_138);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_139);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_140);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_141);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_142);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_143);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_144);
    tcase_add_test(zonedata_Processing_limits,zonedata_Processing_limits_145);
    suite_add_tcase(s,zonedata_Processing_limits);


    return s;
}



int main(void)
{
    int number_failed;
    Suite *s = spf_suite ();
    SRunner *sr = srunner_create (s);
    srunner_set_log (sr, "test.log");
    srunner_run_all (sr, CK_NORMAL);
    number_failed = srunner_ntests_failed (sr);
    srunner_free (sr);
    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}


